# $< stand for the first file of prerequirefiles
# $@ stand for the target files
# $^ stand for all of the prerequirefiles
# %.o:%.cpp stand for the files which replace the %.o's suffix with .cpp
# use -gstabs+ or -gdwarf-2 to get more debug info ??
export MAKEROOT := ..

IMMAIN := AliIM
IMRECEIVER := CmdIMReceiver
IMCONFIRMER := IMConfirmer

IMMAIN_OBJS := AliIM.o BizUIMsgTransfer.o
IMRECEIVER_OBJS := IMReceiver.o CmdIMReceiverMain.o CmdParser.o CmdFuncImpForReceiver.o
IMCONFIRMER_OBJS := IMConfirmer.o

export SRCFILES := $(wildcard *.cpp) 

include $(MAKEROOT)/template.mk

LDFLAGS := -lpthread -lssl -lcrypto -lz -lrt -luuid -lthreadpool -ljsoncpp -lmsgbusclient -lIMMsgBusParam $(LDFLAGS) 

IMMAIN_OBJS_PATH := $(IMMAIN_OBJS:%.o=$(OBJDIR)/%.o)
IMRECEIVER_OBJS_PATH := $(IMRECEIVER_OBJS:%.o=$(OBJDIR)/%.o)
IMCONFIRMER_OBJS_PATH := $(IMCONFIRMER_OBJS:%.o=$(OBJDIR)/%.o)

IMMAIN_PATH := $(BINDIR)/$(IMMAIN)
IMRECEIVER_PATH := $(BINDIR)/$(IMRECEIVER)
IMCONFIRMER_PATH := $(BINDIR)/$(IMCONFIRMER)

all: $(IMMAIN_PATH) $(IMRECEIVER_PATH)

aliim: $(IMMAIN_PATH)

receiver: $(IMRECEIVER_PATH)

$(IMMAIN_PATH): $(IMMAIN_OBJS_PATH) 
	$(CC) -o $@ $^ $(LDFLAGS) -limbiz 

$(IMRECEIVER_PATH): $(IMRECEIVER_OBJS_PATH)  $(OBJDIR)/WWCommonUtility.o
	$(CC) -o $@ $^ $(LDFLAGS) -lreadline 

clean:
	-rm -f *.d  $(IMMAIN_OBJS_PATH) $(IMMAIN_PATH) $(IMRECEIVER_OBJS_PATH) $(IMRECEIVER_PATH)

